﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Excel;

namespace ObjectModel.Excel
{
    public static class WorkbookExtensions
    {
        public static Worksheet GetWorksheetFromName(this Workbook wb, string name)
        {
            Worksheet ws = null;
            
            if (wb != null)
            {
                try { ws = wb.Worksheets[name]; }
                catch (COMException) { throw; }
            }

            return ws;
        }
    }
}
